<template>
  <div class="user-overload-dialog">
    <el-dialog
      v-model="dialogVisible"
      width="400"
      :modal="false"
      align-center
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      @closed="closedHandle"
    >
      <template #header>
        <dialog-title title="提示" />
      </template>
      <div class="content">
        <div class="content-paragraph">
          <svg-icon
            icon-class="download-finish"
            :size="26"
            style="color: #1E8CFF;"
          />
          <span>当前下载用户过多，普通下载线路拥挤。</span>
        </div>
        <div class="content-paragraph">
          <span>推荐您切换至</span>
          <span class="vip-text">VIP专属高速通道，下载速度飙升，畅享极速下载体验！</span>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button
            type="default"
            class="button"
            @click="handleSuccessInner"
          >
            <span>继续下载</span>
          </el-button>
          <el-button
            type="primary"
            class="button"
            @click="handleCancelInner('member')"
          >
            立即提速
          </el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { storeToRefs } from 'pinia'

const props = defineProps({
  handleSuccess: {
    type: Function,
    default:()=>{}
  },
  handleCancel: {
    type: Function,
    default:()=>{}
  }
})

const dialogVisible = ref(true)
const clickType = ref('cancel')
const cancelType = ref('cancel')

type tableListItemType = {
  title?: string;
  background?: string;
  bgColor?: boolean;
  color?: string;
  border?: string;
  borderClass?: string;
}

type tableListType = {
  key: string;
  list:tableListItemType[]
}

const handleSuccessInner = () => {
  clickType.value = 'success'
  dialogVisible.value = false
}

const handleCancelInner = (_cancelType: string) => {
  clickType.value = 'cancel'
  cancelType.value = _cancelType
  dialogVisible.value = false
}

const closedHandle = () => {
  if (clickType.value === 'success') {
    props.handleSuccess()
  } else {
    props.handleCancel(cancelType.value)
  }
}
</script>

<style scoped lang="scss">
.user-overload-dialog {
  .vip-text{
    color:#C3962A;
  }
  .content{
    margin:20px 20px 0 20px ;
    line-height: 24px;
    .content-paragraph + .content-paragraph{
      margin-bottom: 10px;
    }
  }
  .dialog-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin:10px 0;
    gap:20px;
    button{
      width:190px;
      height:42px;
      border-radius: 20px;
    }
  }
}
</style>
